package com.bicon.botu.medical.service.impl

import com.baomidou.mybatisplus.mapper.EntityWrapper
import com.baomidou.mybatisplus.service.impl.ServiceImpl
import com.bicon.botu.core.base.common.Constants
import com.bicon.botu.medical.dao.mapper.AccountMapper
import com.bicon.botu.medical.model.dto.UserAccountParam
import com.bicon.botu.medical.model.entity.Account
import com.bicon.botu.medical.service.IAccountService
import org.springframework.beans.BeanUtils
import org.springframework.stereotype.Service

@Service
open class AccountServiceImpl : ServiceImpl<AccountMapper,Account>(), IAccountService {
    override fun getAccountById(userId: String): Account {
        return Account().selectOne(EntityWrapper<Account>().eq("id", userId).eq("logic_delete", Constants.DEL_LOGIC_NORMAL))
    }

    override fun updateAccount(userAccountParam: UserAccountParam): Boolean {
        val account =  Account()
        account.preUpdate()
        BeanUtils.copyProperties(userAccountParam, account)
        val falg = account.updateById()
        return  falg;
    }
}